﻿<cfsilent>
<cfscript>
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		courseId = event.getArg("CID", event.getArg("CourseID"));

		sql = "SELECT a.institute_id,
					   a.cid,
					   a.course_name 
				FROM t_course a 
				WHERE  a.cid = :courseId ";
				
		queryObj = new query( datasource=application.dnsSlave);
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		
		rs_course = queryObj.execute( sql=sql ).getResult();

		sql = "SELECT a.institute_id,
					   a.institute_name
				FROM t_institute a 
				WHERE a.institute_id = :InstituteId ";
				
		queryObj = new query( datasource=application.dnsSlave);
		queryObj.addParam( name="InstituteId", value=rs_course.institute_id, cfsqltype="cf_sql_varchar" );
		
		rs_department = queryObj.execute( sql=sql ).getResult();
		
		/*课程教学工作量配置*/
	
		sql = "SELECT a.hrt,
					   b.fun_id fun_id1,
					   c.fun_id fun_id2,
					   a.work_divide,
					   a.lang_weight,
					   a.prac_weight   
				FROM t_course_workload a 
					 INNER JOIN t_workload_fun b ON b.fun_id = a.theory_fun 
					 INNER JOIN t_workload_fun c ON c.fun_id = a.practice_fun 
				WHERE a.cid = :courseId ";
		
		queryObj = new query( datasource=application.dnsSlave);
		queryObj.addParam( name="courseId", value=rs_course.cid, cfsqltype="cf_sql_varchar" );
		
		rs_CourseWorkLoad = queryObj.execute( sql=sql ).getResult();

		/*编制分类*/
	
		sql = "SELECT h.hrt,h.type_name 
				FROM t_hr_workload h 
				ORDER BY h.type_name DESC";
				
		queryObj = new query( datasource=application.dnsSlave);
		
		rs_type = queryObj.execute( sql=sql ).getResult();

		/*理论工作量计算公式*/
	
		sql = "SELECT w.fun_id,w.fun_name 
				FROM t_workload_fun w 
				WHERE w.fun_id LIKE 'L%' 
				ORDER BY w.fun_name DESC";
				
		queryObj = new query( datasource=application.dnsSlave);
		
		rs_theroy = queryObj.execute( sql=sql ).getResult();

		/*实践工作量计算公式*/
	
		sql = "SELECT w.fun_id,w.fun_name 
				FROM t_workload_fun w 
				WHERE w.fun_id LIKE 'S%' 
				ORDER BY w.fun_name DESC";
			
		queryObj = new query( datasource=application.dnsSlave);
		
		rs_practive = queryObj.execute( sql=sql ).getResult();
		
		event.setArg("pageTitle", "教学运行基础数据 - 课程系数编辑 -" & rs_course.course_name);
		
		currentTab = event.getArg("TabID", "labSetting");
		
		passArgs = structNew();
		structInsert(passArgs , "DepID", rs_department.institute_id, true );
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat"> <a class="uiButton" href="<cfoutput>#buildURL('courseByDepartment', passArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText"><cfoutput>#rs_department.institute_name#</cfoutput>课程</span></a> </div>
			<div>
				<h2 class="uiHeaderTitle"> <i class="uiHeaderImage img icon16x16 course"></i><cfoutput>#rs_course.course_name#</cfoutput> </h2>
			</div>
		</div>
	</div>
</div>
<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables"> <span <cfif currentTab eq "labSetting">class="active"</cfif> id="labSetting" tabTarget="Setting">课程系数配置</span> </div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				<div id="Setting" class="tabContent">
					<div class="systemNotice">
						<h3><span class="img icon16x16 info"></span><cfoutput>#rs_course.course_name#-课程工作量系数设置</cfoutput></h3>
						<cfif rs_CourseWorkLoad.recordCount GT 0>
							<p>编辑课程工作量计算参数！</p>
							<cfelse>
							<p>新建课程的工作量计算参数！</p>
						</cfif>
					</div>
					<cfif rs_CourseWorkLoad.recordCount EQ 0>
						<form id="formConf" onSubmit="javascript:return processVerfiyForm('formConf');" class="formWrapper" method="post" action="<cfoutput>#buildURL('saveCourseWorkLoadInstituteDo')#</cfoutput>">
							<input type="hidden" name="CourseID" value="<cfoutput>#rs_course.cid#</cfoutput>" />
							<input type="hidden" name="Keywords" value="<cfoutput>#event.getArg("Keywords")#</cfoutput>"/>
							<input type="hidden" name="DepID" value="<cfoutput>#rs_department.institute_id#</cfoutput>" />
							<div class="label"> <b>课程</b>
								<input readonly="readonly" name="CourseName" id="CourseName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#rs_course.course_name#</cfoutput>" />
							</div>
							<div class="label"> <b>编制分类</b>
								<select name="HRWorkLoad">
                                    <cfloop query="rs_type"  >
										<option value="<cfoutput>#rs_type.hrt#</cfoutput>"><cfoutput>#rs_type.type_name#</cfoutput></option>
									</cfloop>
								</select>
							</div>
							<div class="label"> <b>理论公式</b>
								<select name="TWorkLoad">
                                    <cfloop  query="rs_theroy" >
										<option value="<cfoutput>#rs_theroy.fun_id#</cfoutput>"><cfoutput>#rs_theroy.fun_name#</cfoutput></option>
									</cfloop>
								</select>
							</div>
							<div class="label"> <b>实践公式</b>
								<select name="PWorkLoad">
                                    <cfloop query="rs_practive" >
										<option value="<cfoutput>#rs_practive.fun_id#</cfoutput>"><cfoutput>#rs_practive.fun_name#</cfoutput></option>
									</cfloop>
								</select>
							</div>
							<div class="label"> <span class="req">*</span><b>加权系数</b> 双语系数
								<input name="LanguageWeight" type="text" class="typeTinyInt" verification="double" maxlength="4" value="" />
								实践系数
								<input name="PracticeWeight" type="text" class="typeTinyInt" verification="double" maxlength="4" value="" />
							</div>
							<div class="label"> <span class="req">*</span><b>工作量比例</b> 第一主讲
								<input name="FirstWeight" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="" />
								第二主讲
								<input name="SecondWeight" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="" />
								助教
								<input name="ThirdWeight" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="" />
							</div>
							<hr/>
							<div class="lable">
								<input class="button" type="submit" value="保存" />
								<input class="button" type="reset" value="重设表格" />
							</div>
						</form>
						<cfelse>
						<form id="formConf" onSubmit="javascript:return processVerfiyForm('formConf');" class="formWrapper" method="post" action="<cfoutput>#buildURL('saveCourseWorkLoadInstituteDo')#</cfoutput>">
							<input type="hidden" name="CourseID" value="<cfoutput>#rs_course.cid#</cfoutput>" />
							<input type="hidden" name="Keywords" value="<cfoutput>#event.getArg("Keywords")#</cfoutput>"/>
							<input type="hidden" name="DepID" value="<cfoutput>#rs_department.institute_id#</cfoutput>" />
							<div class="label"> <b>课程</b>
								<input readonly="readonly" name="CourseName" id="CourseName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#rs_course.course_name#</cfoutput>" />
							</div>
							<div class="label"> <b>编制分类</b>
								<select name="HRWorkLoad">
                                    <cfloop query="rs_type"  >
										<option <cfif rs_CourseWorkLoad.hrt eq rs_type.hrt>selected="selected"</cfif> value="<cfoutput>#rs_type.hrt#</cfoutput>"><cfoutput>#rs_type.type_name#</cfoutput></option>
									</cfloop>
								</select>
							</div>
							<div class="label"> <b>理论公式</b>
								<select name="TWorkLoad">
									<option value="NOPE">未设置</option>
                                    <cfloop  query="rs_theroy" >
										<option <cfif rs_CourseWorkLoad.fun_id1 eq rs_theroy.fun_id>selected="selected"</cfif> value="<cfoutput>#rs_theroy.fun_id#</cfoutput>"><cfoutput>#rs_theroy.fun_name#</cfoutput></option>
									</cfloop>
								</select>
							</div>
							<div class="label"> <b>实践公式</b>
								<select name="PWorkLoad">
									<option value="NOPE">未设置</option>
                                    <cfloop query="rs_practive" >
										<option <cfif rs_CourseWorkLoad.fun_id2 eq rs_practive.fun_id>selected="selected"</cfif> value="<cfoutput>#rs_practive.fun_id#</cfoutput>"><cfoutput>#rs_practive.fun_name#</cfoutput></option>
									</cfloop>
								</select>
							</div>
							<div class="label"> <span class="req">*</span><b>加权系数</b> 双语系数
								<input name="LanguageWeight" type="text" class="typeTinyInt" verification="double" maxlength="4" value="<cfoutput>#rs_CourseWorkLoad.lang_weight#</cfoutput>" />
								实践系数
								<input name="PracticeWeight" type="text" class="typeTinyInt" verification="double" maxlength="4" value="<cfoutput>#rs_CourseWorkLoad.prac_weight#</cfoutput>" />
							</div>
							<div class="label"> <span class="req">*</span><b>工作量比例</b> 第一主讲
								<input name="FirstWeight" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="<cfoutput>#listToArray(rs_CourseWorkLoad.work_divide,":")[1]#</cfoutput>" />
								第二主讲
								<input name="SecondWeight" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="<cfoutput>#listToArray(rs_CourseWorkLoad.work_divide,":")[2]#</cfoutput>" />
								助教
								<input name="ThirdWeight" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="<cfoutput>#listToArray(rs_CourseWorkLoad.work_divide,":")[3]#</cfoutput>" />
							</div>
							<hr/>
							<div class="lable">
								<input class="button" type="submit" value="更新" />
								<input class="button" type="reset" value="重设表格" />
							</div>
						</form>
					</cfif>
				</div>
			</div>
		</li>
	</ul>
</div>
